const express = require('express')
const app = express()

/**
 * 响应字符串
 *  ● http://127.0.0.1/api/get
 */
app.get('/api/get', (req, res) => {
  res.send('Hello world!')
})

/**
 * 响应 JSON
 *  ● http://127.0.0.1/api/get2?name=张智琦&age=18
 */
app.get('/api/get2', (req, res) => {
  const data = {
    status: 0,
    msg: '成功',
    data: req.query
  }
  res.send(data)
})

app.listen(80, () => {
  console.log('Server running at http://127.0.0.1')
})
